/*
 * @Author: ShiJunJie
 * @Date: 2022-04-06 10:48:35
 * @LastEditors: ShiJunJie
 * @LastEditTime: 2022-04-08 10:44:50
 * @Descripttion: 本地服务配置
 */
import type { ServerOptions } from 'vite'

export default (options?: viteUserOptions) => {
    const server: ServerOptions = {
        host: '0.0.0.0',
        proxy: {
          '/api': {
              target: options.envs.VITE_APP_API_URL, // 你的云服务URL
              changeOrigin: true,
              rewrite: (path: string) => path.replace(/^\/api/, '/api'),
          },
          '/common': {
              target: options.envs.VITE_SLIDING_API, // 你的云服务URL
              changeOrigin: true,
              rewrite: (path: string) => path.replace(/^\/common/, '/common'),
          },
        }
    };

    if(options.envs.VITE_HTTP_PORT){
        server.port = options.envs.VITE_HTTP_PORT
    }
    
    return server;
}
